﻿using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;

namespace Dapper.Library
{
    public interface ICommand<T>
    {

        #region 插入
        /// <summary>
        /// 插入
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        int Insert(T entity);

        /// <summary>
        /// 异步插入
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> InsertAsync(T entity);
        #endregion

        #region 修改
        /// <summary>
        /// 修改实体
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        int Update(T entity);

        /// <summary>
        /// 异步修改实体
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        Task<int> UpdateAsync(T entity);

        /// <summary>
        /// 修改实体
        /// </summary>
        /// <param name="updateExpression"></param>
        /// <returns></returns>
        int UpdateByExp(Expression<Func<T, T>> updateExpression);

        /// <summary>
        /// 多线程修改实体
        /// </summary>
        /// <param name="updateExpression"></param>
        /// <returns></returns>
        Task<int> UpdateByExpAsync(Expression<Func<T, T>> updateExpression);
        #endregion

        #region 删除
        /// <summary>
        /// 删除 
        /// </summary>
        /// <returns></returns>
        int Delete();

        /// <summary>
        /// 异步删除
        /// </summary>
        /// <returns></returns>
        Task<int> DeleteAsync();
        #endregion


    }
}
